#include <ev.h>
#include <stdio.h>

//libev test
//multiple timer test
//gcc test.c -lm


void timer_cb(struct ev_loop *main_loop, ev_timer *timer_w, int e)
{
    printf("timer callback %d\n", *(int *)timer_w->data);
}

void timer_cb_1(struct ev_loop *main_loop, ev_timer *timer_w, int e)
{
    printf("timer ***callback %d\n", *(int *)timer_w->data);
    timer_w->data;
}
int main()
{
    struct ev_loop *main_loop = ev_default_loop(0);
    ev_timer g_timer;
    ev_timer g_timer1;
    int a = 5;
    int b = 10 ;
    g_timer.data = &a;
    g_timer1.data = &b;
    //timer init 
    ev_timer_init(&g_timer, timer_cb, 2, 1);
    ev_timer_init(&g_timer1, timer_cb_1, 0.5, 0.5);
    //register 2 timer events
    ev_timer_start(main_loop, &g_timer);
    ev_timer_start(main_loop, &g_timer1);
    ev_run(main_loop, 0);
    printf("hello \n");
}